{% extends theme("layout.html") %}

{% from "macros/_post.html" import render_comment, markdown_link with context %}

{% block content %}
<h2>
{% if post.permissions.vote %}
<span id="vote-{{ post.id }}">
    <a href="#" onclick="newsmeme.vote_post('{{ url_for('post.upvote', post_id=post.id) }}'); return false;"><img src="{{ theme_static("images/up-icon.png") }}"></a>
    <a href="#" onclick="newsmeme.vote_post('{{ url_for('post.downvote', post_id=post.id) }}'); return false;"><img src="{{ theme_static("images/down-icon.png") }}"></a>  
</span>
{% endif %}

{% if post.link %}
<a href="{{ post.link }}">{{ post.title }}</a>
<span class="domain">&rarr; {{ post.domain }}</span>
{% else %}
{{ post.title }}
{% endif %}

</h2>

{% if post.description %}
{{ post.markdown }}
{% endif %}

{% if post.tags %}
<ul class="tags">
    {% for tag, url in post.linked_taglist %}
    <li><a href="{{ url }}">{{ tag }}</a></li>
    {% endfor %}
</ul>
{% endif %}

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a href="http://www.addthis.com/bookmark.php?v=250&amp;username=xa-4c5e6e125f2a74cb" class="addthis_button_compact">Share</a>
<span class="addthis_separator">|</span>
<a class="addthis_button_facebook"></a>
<a class="addthis_button_myspace"></a>
<a class="addthis_button_google"></a>
<a class="addthis_button_twitter"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4c5e6e125f2a74cb"></script>
<!-- AddThis Button END -->



<p class="post-info">
{{ _('Posted') }} {{ post.date_created|timesince }} {{ _('by') }} 
<a href="{{ url_for('user.posts', username=post.author.username) }}">{{ post.author.username }}</a> 
| <a href="{{ post.permalink }}">permalink</a> 
    {% if g.user %}
    {% if post.permissions.edit %}
    | <a href="{{ url_for('post.edit', post_id=post.id) }}">edit this post</a> 
    {% if post.permissions.delete %}
    | <a href="#" onclick="$('#delete-post').toggle(); return false;">delete this post</a> 
    <div id="delete-post" style="display:none;">
        <strong>{{ _('Are you sure you want to delete this post ?') }}</strong>
        <a href="#" onclick="newsmeme.ajax_post('{{ url_for('post.delete', post_id=post.id) }}'); return false;">{{ _('yes') }}</a> / 
        <a href="#" onclick="$('#delete-post').toggle(); return false;">{{ _('no') }}</a>
    </div>
    {% endif %}
    {% endif %}
    <h3>{{ _('Add a comment') }}</h3>
    <form id="comment-form" method="POST" action="{{ url_for('post.add_comment', post_id=post.id) }}">
        {{ comment_form.hidden_tag() }}
        <ul>
        <li>
            {{ comment_form.comment }}
        </li>
        <li>
        <input type="submit" value="{{ _('add comment') }}">
        </li>
        <li>
            {{ markdown_link() }}
        </li>
        </ul>
    </form>
    {% endif %}
</p>

{% if post.comments %}
<h3>{{ _('Comments') }}</h3>
<ul class="comments">
    {% for comment in post.comments %}
    {{ render_comment(comment) }}
    {% endfor %}
</ul>
{% else %}
{{ _('No comments have been posted yet.') }} 
{% endif %}


{% endblock %}
